package com.r7data.dbstruct.entity;

import com.r7data.dbstruct.code.ValueMetaCode;

/**
 * 表的列基本信息
 * @author admin
 *
 */
public class ColumnMetaInfo {
	/** ========== 实际使用到的信息 ========== **/
	/** @字段名称 **/
	private String fieldName;
	/** @类型 **/
	private int valtype;
	private String valTypeName;
	/** @长度 **/
	private int length;
	/** @精度 **/
	private int precision;
	/** @步骤来源 **/
	private String stepOrigin;
	/** @存储 **/
	private int storageType;
	private String storageTypeCode;
	/** @掩码 **/
	private String conversionMask;
	/** @货币符号？ **/
	private String currencySymbol;
	/** @小数点符号 **/
	private String decimalSymbol;
	/** @数字分组符号？ **/
	private String groupingSymbol;
	/** @去除空格符 **/
	private int trimType;
	private String trimTypeCode;
	/** @备注 **/
	private String comments;
	
	/** ========== 以下为其他的信息 ========== **/
	/** 原始字段类型编码 **/
	private int originalColumnType;
	/** 原始字段类型名称 **/
	private String originalColumnTypeName;
	/** 原始精度 **/
	private int originalPrecision;
	/** 原始小数点后位数 **/
	private int originalScale;
	/** 原始是否有符号 **/
	private boolean originalSigned;
	/** 是否是 clob **/
	private boolean largeTextField;
	
	/**
	 * 初始化
	 */
	public ColumnMetaInfo() {
		this.decimalSymbol = ValueMetaCode.decimal_symbol;
		this.groupingSymbol = ValueMetaCode.groupingSymbol;
	}
	
	public String getFieldName() {
		return fieldName;
	}
	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}
	public int getValtype() {
		return valtype;
	}
	public void setValtype(int valtype) {
		this.valtype = valtype;
	}
	public void setValTypeName(String valTypeName) {
		this.valTypeName = valTypeName;
	}
	public int getLength() {
		return length;
	}
	public void setLength(int length) {
		this.length = length;
	}
	public int getPrecision() {
		return precision;
	}
	public void setPrecision(int precision) {
		this.precision = precision;
	}
	public String getStepOrigin() {
		return stepOrigin;
	}
	public void setStepOrigin(String stepOrigin) {
		this.stepOrigin = stepOrigin;
	}
	public int getStorageType() {
		return storageType;
	}
	public void setStorageType(int storageType) {
		this.storageType = storageType;
	}
	public void setStorageTypeCode(String storageTypeCode) {
		this.storageTypeCode = storageTypeCode;
	}
	public String getConversionMask() {
		return conversionMask;
	}
	public void setConversionMask(String conversionMask) {
		this.conversionMask = conversionMask;
	}
	public String getCurrencySymbol() {
		return currencySymbol;
	}
	public void setCurrencySymbol(String currencySymbol) {
		this.currencySymbol = currencySymbol;
	}
	public String getDecimalSymbol() {
		return decimalSymbol;
	}
	public void setDecimalSymbol(String decimalSymbol) {
		this.decimalSymbol = decimalSymbol;
	}
	public String getGroupingSymbol() {
		return groupingSymbol;
	}
	public void setGroupingSymbol(String groupingSymbol) {
		this.groupingSymbol = groupingSymbol;
	}
	public int getTrimType() {
		return trimType;
	}
	public void setTrimType(int trimType) {
		this.trimType = trimType;
	}
	
	public void setTrimTypeCode(String trimTypeCode) {
		this.trimTypeCode = trimTypeCode;
	}
	public String getComments() {
		return comments;
	}
	public void setComments(String comments) {
		this.comments = comments;
	}
	public int getOriginalColumnType() {
		return originalColumnType;
	}
	public void setOriginalColumnType(int originalColumnType) {
		this.originalColumnType = originalColumnType;
	}
	public String getOriginalColumnTypeName() {
		return originalColumnTypeName;
	}
	public void setOriginalColumnTypeName(String originalColumnTypeName) {
		this.originalColumnTypeName = originalColumnTypeName;
	}
	public int getOriginalPrecision() {
		return originalPrecision;
	}
	public void setOriginalPrecision(int originalPrecision) {
		this.originalPrecision = originalPrecision;
	}
	public int getOriginalScale() {
		return originalScale;
	}
	public void setOriginalScale(int originalScale) {
		this.originalScale = originalScale;
	}
	public boolean isOriginalSigned() {
		return originalSigned;
	}
	public void setOriginalSigned(boolean originalSigned) {
		this.originalSigned = originalSigned;
	}
	public boolean isLargeTextField() {
		return largeTextField;
	}
	public void setLargeTextField(boolean largeTextField) {
		this.largeTextField = largeTextField;
	}
	
	/** ========== get/set finish ========== **/
	public String getValTypeName() {
		this.valTypeName = ValueMetaCode.getValTypeName(valtype);
		return valTypeName;
	}
	public String getStorageTypeCode() {
		this.storageTypeCode = ValueMetaCode.getStorageTypeCode(storageType);
		
		return storageTypeCode;
	}
	public String getTrimTypeCode() {
		this.trimTypeCode = ValueMetaCode.getTrimTypeCode(trimType);
		return trimTypeCode;
	}
	
	/**
	 * 设置默认值
	 */
	public void setDefaultConversionMask() {
		// Set some sensible default mask on the numbers
		//
		switch (valtype) {
		case ValueMetaCode.TYPE_INTEGER:
			setConversionMask("#;-#");
			
			break;
		case ValueMetaCode.TYPE_NUMBER:
			setConversionMask("#.#;-#.#");
			
			break;
		case ValueMetaCode.TYPE_BIGNUMBER:
			
			setConversionMask("#.###############################################;"
					+ "-#.###############################################");
			
			setGroupingSymbol(null);
			setDecimalSymbol("."); // For backward compatibility reasons!
			break;
		default:
			break;
		}
	}

}
